# Copyright 2010-2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library")

package(
    default_visibility = ["//visibility:public"],
)

proto_library(
    name = "gscip_proto",
    srcs = ["gscip.proto"],
)

cc_proto_library(
    name = "gscip_cc_proto",
    deps = [":gscip_proto"],
)

py_proto_library(
    name = "gscip_proto_py_pb2",
    deps = [":gscip_proto"],
)

# NOTE(user): this file should ideally not have a compile time dependency on
# SCIP, so it can be used in client code.
cc_library(
    name = "gscip_parameters",
    srcs = ["gscip_parameters.cc"],
    hdrs = ["gscip_parameters.h"],
    deps = [
        ":gscip_cc_proto",
        "//ortools/base:status_macros",
        "@abseil-cpp//absl/strings",
        "@abseil-cpp//absl/time",
    ],
)

cc_library(
    name = "legacy_scip_params",
    srcs = ["legacy_scip_params.cc"],
    hdrs = ["legacy_scip_params.h"],
    deps = [
        "//ortools/linear_solver:scip_helper_macros",
        "@abseil-cpp//absl/status",
        "@abseil-cpp//absl/strings",
        "@abseil-cpp//absl/strings:str_format",
        "@scip",
    ],
)

cc_library(
    name = "gscip",
    srcs = [
        "gscip.cc",
        "gscip_event_handler.cc",
    ],
    hdrs = [
        "gscip.h",
        "gscip_event_handler.h",
    ],
    deps = [
        ":gscip_cc_proto",
        ":gscip_message_handler",
        ":gscip_parameters",
        ":legacy_scip_params",
        "//ortools/base",
        "//ortools/base:status_builder",
        "//ortools/base:status_macros",
        "//ortools/linear_solver:scip_helper_macros",
        "//ortools/port:proto_utils",
        "//ortools/util:status_macros",
        "@abseil-cpp//absl/cleanup",
        "@abseil-cpp//absl/container:flat_hash_map",
        "@abseil-cpp//absl/container:flat_hash_set",
        "@abseil-cpp//absl/status",
        "@abseil-cpp//absl/status:statusor",
        "@abseil-cpp//absl/strings",
        "@scip",
    ],
)

cc_library(
    name = "gscip_ext",
    srcs = ["gscip_ext.cc"],
    hdrs = ["gscip_ext.h"],
    deps = [
        ":gscip",
        "//ortools/base:status_macros",
        "@abseil-cpp//absl/status",
        "@scip",
    ],
)

cc_library(
    name = "gscip_message_handler",
    srcs = ["gscip_message_handler.cc"],
    hdrs = ["gscip_message_handler.h"],
    deps = [
        "//ortools/base",
        "//ortools/linear_solver:scip_helper_macros",
        "@abseil-cpp//absl/status:statusor",
        "@abseil-cpp//absl/strings",
        "@scip",
    ],
)

cc_library(
    name = "gscip_callback_result",
    srcs = ["gscip_callback_result.cc"],
    hdrs = ["gscip_callback_result.h"],
    deps = ["@scip"],
)

cc_library(
    name = "gscip_constraint_handler",
    srcs = ["gscip_constraint_handler.cc"],
    hdrs = ["gscip_constraint_handler.h"],
    deps = [
        ":gscip",
        ":gscip_callback_result",
        "//ortools/linear_solver:scip_helper_macros",
        "@abseil-cpp//absl/log",
        "@abseil-cpp//absl/log:check",
        "@abseil-cpp//absl/status",
        "@abseil-cpp//absl/status:statusor",
        "@abseil-cpp//absl/types:span",
        "@scip",
    ],
)
